<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>完善资料</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <!--weui.min.css-->
    <link rel="stylesheet" href="/static/index/css/page/base.css"/>
    <link rel="stylesheet" href="/static/index/css/page/font.css"/>
    <link rel="stylesheet" href="/static/index/jquery_weui/css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="/static/index/jquery_weui/lib/weui.min.css">
    <!--jquery-weui.min.css-->
    <link rel="stylesheet" type="text/css" href="/static/index/jquery_weui/css/jquery-weui.min.css">
    <link rel="stylesheet" href="/static/index/css/page/add.css" />
</head>
<body>
<script type="text/javascript" src="/static/index/jquery_weui/lib/jquery-2.1.4.js"></script>
<!-- jquery-2.1.4 -->
<script type="text/javascript" src="/static/index/jquery_weui/js/jquery-weui.min.js"></script>
<!-- jquery-weui.min.js -->
<div class="pageControl complete bg-f5">
    <!--主体-->
    <div class="main">
        <div class="bg-di"></div>
        <div class="msui_nav msui_navTop">
            <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
            <h1 class="msui_navTop-title">完善资料</h1>
        </div>
    </div>
    <div class="weui-cell bg-fff">
        <div class="weui-cell__hd">
            <img src="/static/index/img/ws9.png" alt="">
        </div>
        <div class="weui-cell__bd">
            <input type="text" class="weui-input" placeholder="请输入您的昵称" id="name" value="{if $info.name}{$info.name}{/if}">
        </div>
    </div>

    <div class="weui-cell bg-fff">
        <div class="weui-cell__hd">
            <img src="/static/index/img/ws7.png" alt="">
        </div>
        <div class="weui-cell__bd">
            <input type="text" class="weui-input sex_val" value="{if $info.sex eq 1}男{else}女{/if}" readonly="true">
        </div>
    </div>

    <!--<div class="weui-cell bg-fff">
        <div class="weui-cell__hd">
            <img src="/static/index/img/ws3.png" alt="">
        </div>
        <div class="weui-cell__bd">
            <input type="text" class="weui-input" id="birthday" placeholder="请选择出生日期">
        </div>
    </div>-->
    <div class="weui-cell bg-fff">
        <div class="weui-cell__hd">
            <img src="/static/index/img/ws8.png" alt="">
        </div>
        <div class="weui-cell__bd">
            <input type="text" class="weui-input" placeholder="请输入您的年龄" id="age" value="{if $info.age gt 0}{$info.age}{/if}" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
        </div>
    </div>
    <div class="weui-cell bg-fff">
        <div class="weui-cell__hd">
            <img src="/static/index/images/p5.png" alt=""/>
        </div>
        <div class="weui-cell__bd">
            <input type="text" class="weui-input tel" placeholder="请输入您的手机号" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
        </div>
    </div>
    <div class="weui-cell bg-fff">
        <div class="weui-cell__hd">
            <img src="/static/index/images/yzm.png" alt=""/>
        </div>
        <div class="weui-cell__bd">
            <input type="text" class="weui-input yzm" placeholder="请输入您的短信验证码" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
        </div>
        <div class="weui-cell__ft">
            <button class="weui-vcode-btn" id="send_yzm">获取验证码</button>
        </div>
    </div>
    <a href="javascript:;" class="complete_btn">完成</a>
</div>
<script src="/static/index/jquery_weui/js/swiper.min.js"></script>
</body>
</html>
<script>

    function verifyCode(target,time,mtarget,message) {
        if (time == 0) {
            target.removeAttr('disabled');
            target.html('获取验证码');
            if (mtarget) {
                mtarget.closest('p').css('display', 'none');
                mtarget.html(message);
            }
        }else {
            target.attr('disabled', 'disabled');
            target.html(time + 's后可重新获取');
            if (mtarget) {
                mtarget.closest('p').css('display', 'block');
                mtarget.html(message);
            }
            time--;
            setTimeout(function () {
                verifyCode(target, time);
            }, 1000)
        }
    }

    $(".my-flex").on('click','a',function (e) {
        e.preventDefault();
        $(this).addClass('active').siblings().removeClass('active');
    })
    $('.complete_btn').click(function(){
        var id = {$id};
        var name = $('#name').val();
        var age = $('#age').val();
        var sex_val =$(".sex_val").val();
        var tel = $('.tel').val();
        var yzm = $('.yzm').val();

        if(sex_val == '男'){
            var sex = 1;
        }else{
            var sex = 0;
        }
        $.post(
            "/index/personal/complete",
            {id:id,name:name,age:age,sex:sex,tel:tel,yzm:yzm},
            function(data){
                if(data.code == 1){
                    alert(data.msg);
                    window.location.href="/index/index/index";
                }else{
                    alert(data.msg);
                }
            },'json'
        )
    })
    $('#send_yzm').on('click',function () {
        var tel = $('.tel').val();
        if(tel){
            $.post(
                '/index/sms/info_bding',
                {tel:tel},
                function (data) {
                    if(data.code == 200){
                        verifyCode($('#send_yzm'),60);
                    }else{
                        alert(data.msg);
                    }
                },'json'
            )
        }else{
            alert('请输入您的手机号！');
        }
    })
</script>

